package router

import (
	"github.com/gin-gonic/gin"
	"gopkg.in/ini.v1"
	"quantization_trading/src/router/api"
)

func InitRouter(conf *ini.File){
	AppModel := conf.Section("server").Key("app_model").MustString("debug")
	HttpPort := conf.Section("server").Key("http_port").MustString(":8084")
	gin.SetMode(AppModel)
	r := gin.Default()
	router := r.Group("")
	{
		//模块的路由接口
		router.GET("/",api.Hello)
		// 价格
		router.POST("/price",api.AddPrice)
		router.DELETE("/price",api.DelPrice)
		router.GET("/price",api.FindAllPrice)
		//账号
		router.POST("/account",api.AddAccount)
		router.DELETE("/account",api.DelAccount)
		router.GET("/account",api.FindAllAccount)
		//策略
		router.POST("new_strategy",api.NewStrategy)
		router.POST("/stop_strategy",api.StopStrategy)
		router.POST("/start_strategy",api.StartStrategy)
		router.POST("/del_strategy",api.DelStrategy)
		router.GET("/strategy",api.FindAllStartegy)
		router.GET("/strategy/:accountName",api.FindByAccountNameStrategy)

		//订单
		router.GET("/useorder",api.FindUseAllOrder)
		router.GET("/order",api.FindAllOrder)
		router.POST("/order_limit",api.LimitOrder)
		router.POST("/order_market",api.MarketOrder)
		router.POST("/order_limit_all",api.LimitCloseAllOrder)
		router.POST("/order_market_all",api.MarketCloseAllOrder)
		router.POST("/orderById",api.FindOrder)
	}
	r.Run(HttpPort)
}
